﻿@model PNProject.Core.LibModel
@using PNProject;
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/AdminLayout.cshtml";
    int i = 0;
}

<div class="admin_head">
Tạo mới một phần tử thư viện
</div>
<script src="/Scripts/jquery-1.5.1.js" type="text/javascript"></script>

<div class="admin_content">

@using (Html.BeginForm("Create", "AdminLibraries", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
    @Html.HiddenFor(a=>a.Lang)
    @Html.HiddenFor(a=>a.Type)
    @Html.HiddenFor(a=>a.IsPublic)
    @Html.HiddenFor(a=>a.LibContent)
    
        <legend>Form nhập - Thư viện</legend>
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>Ngôn ngữ
</div>
<div>
<select id="select_lang">
<option value="0">Tiếng Việt</option>
<option value="1">Tiếng Anh</option>
</select>
</div>
<br />
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>Loại nội dung
</div>
<div>
<select id="select_type">
<option value="0">Tập tin</option>
<option value="1">Video</option>
</select>
</div>
<br />
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>Phân quyền
</div>
<div>
<select id="select_share">
<option value="0">Chia sẻ</option>
<option value="1">Không chia sẻ</option>
</select>
</div>
<br />
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>Tiêu đề
</div>
<div class="editor-field">
        @Html.EditorFor(model => model.Title)
</div>
<br />

<div id="file_upload" class="title">
File đính kèm <span style="color:Red">(*.doc, *.docx, *.pdf, *.ppt, *.xls, *.xlsx, *.jpg, *.jpeg, *.png, *.gif )</span><br />
<input type="file" name="file" />
</div>
<div id="url" style="display:none;">
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>URL
</div>
<div class="editor-field">
        @Html.EditorFor(model => model.URL)
</div>
</div>
<br />
<div class="title">
<img src="/Images/Base/chimuc.jpg" style="margin-right:10px; margin-bottom:1px;"/>Nội dung
</div>
<textarea class="ckeditor" id="editor1" rows="10" style="width:540px; height:300px; overflow-x:hidden;"></textarea>

        <p>
            <input id="main-submit" type="submit" value="Tạo mới" />
        </p>
</fieldset>
}


</div>
<script type="text/javascript">
    $(document).ready(function () {
        $(select_type).val("0");
        $(select_type).change(function () {
            if ($(select_type).val() == "0") {
                $(url).css("display", "none");
                $(file_upload).css("display", "block");
            }
            else {
                $(url).css("display", "block");
                $(file_upload).css("display", "none");
            }
        });

        $("#main-submit").click(function () {
            var value1 = CKEDITOR.instances['editor1'].getData();
            $("#LibContent").val(value1);
            var lang = $(select_lang).val();
            if (lang == "0") {
                $("#Lang").val("True");
            }
            else {
                $("#Lang").val("False");
            }

            var share = $(select_share).val();
            if (share == "0") {
                $("#IsPublic").val("True");
            }
            else {
                $("#IsPublic").val("False");
            }

            $("#Type").val($(select_type).val());

        });
    });
</script>

